/**
 * @author davelenz
 */
package nl.ypmits.utils.as3.data.remoting {
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.Responder;

	public class Remoting extends EventDispatcher {

		private var rs : RemotingService;
		
		public var classpath : String;
		public var data : *;

		
		function Remoting( _gateway : String, _classpath : String, _string : String = "0" ) {
			classpath = _classpath;
			
			getData( _gateway, _classpath, _string );
		}

		
		private function getData( _gateway : String, _classpath : String, _string : String = "0" ) : void {
			rs = new RemotingService( _gateway );
			var responder : Responder = new Responder( onResult, onFault );
			rs.call( _classpath, responder, _string );
		}

		
		private function onResult(re : *) : void {
			data = re.serverInfo;
			dispatchEvent( new Event( Event.COMPLETE ) );
		}

		
		private function onFault(fault : *) : void {
			trace( fault );
		}
	}
}